# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=polymc
pkgver=1.3.2
pkgrel=0
_commit_libnbtplusplus="2203af7eeb48c45398139b583615134efd8d407f"
_commit_quazip="6117161af08e366c37499895b00ef62f93adc345"
pkgdesc="A custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once"
url="https://polymc.org/"
# blocked on riscv64 by openjdk
# armhf and armv7 unsupported upstream
arch="all !riscv64 !armhf !armv7"
license="GPL-3.0-only AND Apache-2.0"
depends="
	openjdk8-jre
	"
case "$CARCH" in
	x86) ;;
	*) depends="$depends openjdk17-jre" ;;
esac

makedepends="
	cmake
	qt5-qtbase-dev
	openjdk8
	"
source="https://github.com/PolyMC/PolyMC/archive/$pkgver/polymc-$pkgver.tar.gz
	https://github.com/MultiMC/libnbtplusplus/archive/$_commit_libnbtplusplus/libnbtplusplus-$_commit_libnbtplusplus.tar.gz
	https://github.com/stachenov/quazip/archive/$_commit_quazip/quazip-$_commit_quazip.tar.gz
	"
subpackages="$pkgname-doc"
builddir="$srcdir/PolyMC-$pkgver"

prepare() {
	default_prepare

	rmdir \
		libraries/libnbtplusplus \
		libraries/quazip
	mv "$srcdir"/libnbtplusplus-$_commit_libnbtplusplus libraries/libnbtplusplus
	mv "$srcdir"/quazip-$_commit_quazip libraries/quazip
}

build() {
	JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk cmake -B build \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
be00a5caa3867c4844112bab9ba9ce155d8cb16923430f6c21ddfc6f70d822fc1dc622339fd59ad1ec708deeb2a69deaf3e6c6b510ccfab2f3f0a57aa523ef59  polymc-1.3.2.tar.gz
32db7836a09e1aeb18240426d21dfacd4b751b058de0299e61e75ac5c48e8b879f2d271c64c263de99f4013b300a570777e722476f51515b4596e49ad63713c6  libnbtplusplus-2203af7eeb48c45398139b583615134efd8d407f.tar.gz
943bfb6d2d2a30078c2cca3feb53e22340c9069638ec2a19a450389dbcf1dcaed63c6958b96206c136a577d7550630b56603dc5d3c2cf1b6d40e0961c054fcee  quazip-6117161af08e366c37499895b00ef62f93adc345.tar.gz
"
